//ACCEPTED...
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>

using namespace std;
typedef long long ll;

class LuckyRemainder{
	public:
	int getLuckyRemainder(string X);
};

int LuckyRemainder::getLuckyRemainder(string X){
	int sum=0, n = X.size(), a = (int)pow(2.0, n-1);
		for(int i=0;i<n;i++)sum += (((X[i]-'0')*a)%9);
		return sum%9;
}

//*/
int main(){
	freopen("in.txt","r",stdin);freopen("out.txt","w",stdout);
	LuckyRemainder x;
	
	cout<<x.getLuckyRemainder("123")<<endl;
	return 0;
}
//*/

